<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>组建基础</title>
</head>
<body>
  <div id="components-demo">
    <!-- 组件是可以复用的 -->
    <button-counter></button-counter>
    <button-counter></button-counter>
    <button-counter></button-counter>
  </div>

  <!-- 通过prop向子组件传递数据 -->
  <div id='app2'>
    <blog-post title="My journey with Vue"></blog-post>
  </div>
  <div id="blog-post-demo">
    <blog-post
      v-for='post in posts'
      :key='post.id'
      :title='post.title'
    ></blog-post>
  </div>
</body>
<script src="./vue1111.js"></script>
<script>
  Vue.component('button-counter',{
    data(){
      return {
        count:0
      }
    },
    template:`<button @click='count++'>You can clicked me {{count}} times.</button>`
  });
  new Vue({
    el:'#components-demo'
  });

  Vue.component('blog-post',{
    props:['title'],
    
    template:`<h3> {{title}}</h3>`
  })
  new Vue({
    el:'#app2'
  });

  new Vue({
    el:'#blog-post-demo',
    data:{
      posts:[
        {id: 1, title: 'My journey with Vue' },
        { id: 2, title: 'Blogging with Vue' },
        { id: 3, title: 'Why Vue is so fun' }
      ]
    }
  });
</script>
</html>